/*
  Created on Jul 25, 2005
  (C) 2005 
  @author Michael Long

  This program is free software; you can redistribute it and/or
  modify it under the terms of Version 2 of the GNU General Public 
  License.
  
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.
  
  You should have received a copy of the GNU Library General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

package sxe.core.video;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

import snobject.snImage;
import snobject.snObject;
import snobject.snObjectArgList;
import step.EvaluationFailure;
import step.FunctionWrapper;

public class drawstring extends FunctionWrapper {

	@Override
	public snObject Call(snObjectArgList argv) 
		throws EvaluationFailure,
			ClassCastException {
	   snImage sni = argv.popImage();
	   String str = argv.popString().getString();
	   
	   /* do not directly manipulate the original image, instead work with a copy */
	   BufferedImage buffImg = sni.getImageCopy(); 
	   
	   /* Overlay curent time and date onto the image */
	   Graphics2D g = buffImg.createGraphics();
       g.setColor(Color.BLACK);
       g.setFont(new Font("Verdana", Font.BOLD, 16));
       g.drawString(str, 10, 25);
       g.setColor(Color.CYAN);
       g.drawString(str, 8, 22);
       
       return new snImage(buffImg);
	}
	
}
